package com.tianqu.tms.www.member.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.entity.Member;
import com.tianqu.tms.www.member.actionform.MemberInputActionForm;
import com.tianqu.tms.www.member.viewhelper.MemberInputViewHelper;
/**
 * 会员登录信息修改登录密码信息确认Action
 * 
 * @author tianshifu
 *
 */
public class MemberUDLoginPasswordConfirmAction extends TmsAction {

	private static final String MEMBERID = "memId";//会员ID
	private Logger logger = Logger.getLogger(MemberUDLoginPasswordConfirmAction.class);

	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		logger.debug(this.getClass().getName() + "#execute was called.");
		
		//从form中获取密码信息
		MemberInputActionForm inputForm = (MemberInputActionForm)form;
		//从页面获取旧密码到数据库中进行比对
		Member member = Member.getInstance();
		String memberId = (String)uc.getAttribute(MEMBERID);
		member = member.findMemberInfoByMemId(memberId);

		MemberInputViewHelper view = (MemberInputViewHelper)uc.getAttribute(TmsConstants.VIEWHELP); 
		view.setPassword(inputForm.getNew_password());
		view.setMemberId(inputForm.getMemberId());
		
		request.setAttribute(TmsConstants.VIEWHELP, view);
		
		uc.setAttribute(TmsConstants.VIEWHELP, view);
		logger.debug(this.getClass().getName() + "#execute was completed.");
		return mapping.findForward(TmsConstants.SUCCESS);
	}

}
